<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>注册页面</title>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="css/login.css">
  <script>
    function validateRegisterForm() {
      var username = document.getElementById("username").value;
      var password = document.getElementById("password").value;
      var usernamePattern = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/;
      var passwordPattern = /^[0-9]+$/;

      if (username === "" || password === "") {
        alert("用户名和密码不能为空");
        return false;
      }
      if (!usernamePattern.test(username)) {
        alert("用户名应为中文、字母或数字的组合");
        return false;
      }
      if (!passwordPattern.test(password)) {
        alert("密码应为纯数字");
        return false;
      }
      if (username.length < 3 || username.length > 20) {
        alert("用户名长度应在3到20个字符之间");
        return false;
      }
      if (password.length < 6 || password.length > 20) {
        alert("密码长度应在6到20个字符之间");
        return false;
      }
      return true;
    }
  </script>
</head>
<body>
<div class="login-container">
  <h2>注册</h2>
  <form action="register-servlet" method="POST" onsubmit="return validateRegisterForm()">
    <label for="username">Username:</label>
    <input type="text" id="username" name="username">

    <label for="password">Password:</label>
    <input type="password" id="password" name="password">

    <button type="submit">Register</button>
  </form>
</div>
</body>
</html>